import Vue from "vue";

export const state = {
  //用户信息中有token
  userInfo: {},
  //选择的农场id
  farmId:"",
  //员工id'
  employeeId:""
};
export const mutations = {
  //储存用户信息
  setUserInfo(state, data) {
  	if (data) {
  		state.userInfo =  Object.assign(state.userInfo,data);
  		// #ifdef H5
  		// window.sessionStorage.setItem('userInfo', JSON.stringify(state.userInfo));
  		// #endif
  		// #ifndef H5
  		// uni.setStorageSync('userInfo', state.userInfo);
  		// #endif
  	}
  },
  //存储农场id
  setFarmId(state,data){
	if(data){
		state.farmId = data
	}  
  },
  //存储员工id
  setEmployeeId(state,data){
  	if(data){
  		state.employeeId = data
  	}  
  },
  // 退出APP
  emptyUserInfo(state) {
  	state.userInfo = {};
  	// #ifdef H5
  	// window.sessionStorage.removeItem("userInfo");
  	// #endif
  	// #ifndef H5
  	// uni.removeStorageSync("userInfo");
  	// #endif
  },
};
export const actions = {
  
};
